function start(){
	$("#header1").load("../header.html");
	$("#last").load("../footer.html #footer1");
	
	var myUserName = "myUserName";
	var myPwd = "myPwd"
	var isLogin = "isLogin";
	var isbuy = "isbuy";
	var goodMessage = "goodMessage";
	var userAddress = "userAddress";   //一个键名。表示收货人的地址
	var isHaveAddress = "isHaveAddress"; //一个键名，表示cookie中是否有收货地址
	var  totalPrices = "totalPrices";   //表示cookie订单中存放的商品总价
	var orderNumber = "orderNumber";    //表示cookie订单中存放的订单号
	var orderGoods = "orderGoods"       //表示订单中的商品信息
	var collectGood = "collectGood";    //表示收藏中的商品信息
	var isCollect = "isCollect";       //标识是否收藏了商品
	
	//主内容区切换
	tabChange();
	function tabChange(){
		$(".myzhongjiu").on("click",function(){
			$(".myWine").show();
			$(".detailOrder").hide()
			$(".mycollect").hide()
			$(".resetPwd").hide();
			$(".controlAddress").hide();
		});
		$(".mydingdan").on("click",function(){
			$(".detailOrder").show()
			$(".myWine").hide();
			$(".mycollect").hide();
			$(".resetPwd").hide();
			$(".controlAddress").hide();
		});
		$(".mycollectspace").on("click",function(){
			$(".detailOrder").hide()
			$(".myWine").hide();
			$(".mycollect").show();
			$(".resetPwd").hide();
			$(".controlAddress").hide();
		});
		$(".mima").on("click",function(){
			$(".detailOrder").hide()
			$(".myWine").hide();
			$(".mycollect").hide();
			$(".resetPwd").show();
			$(".controlAddress").hide();
		});
		$(".address").on("click",function(){
			$(".detailOrder").hide()
			$(".myWine").hide();
			$(".mycollect").hide();
			$(".resetPwd").hide();
			$(".controlAddress").show();
		});
	};
	//订单里的tab切换
	orderTab();
	function orderTab(){
		$(".order_tab_change").find("li").on("click",function(){
			$(this).addClass("active").siblings().removeClass("active");
		});
	};
	//收藏夹的收藏商品功能
	collectShow();
	function collectShow(){
		if(getCookie(isCollect) == 1){
			$(".collect").show();
			var obj = JSON.parse(getCookie(collectGood));
			console.log(obj)
			$(".collect").find("img").attr("src",obj.img);
			$(".collectName a").html(obj.goodname);
			$(".collectName a").attr("title",obj.goodname);
			$(".collectPrise").html(obj.goodprise);
		}else{
			$(".collect").html("");
		}
	};
	$(".add2").on("click",function(){
		updateCookie(goodMessage,getCookie(collectGood),5);
		window.location = "../shopcar/shopcar.html";
	});
	$(".Outcollect").on("click",function(){
		$(".collect").remove();
		updateCookie(isCollect,0,5);
		deleteCookie(collectGood);
	});
	//我的中酒的显示功能
	zhongjiuShow();
	function zhongjiuShow(){
		if(getCookie(isLogin) != 1){
			$(".tell").html("<a href='../registerlogin/login.html'>登陆</a>")
		}else{
			var obj = JSON.parse(getCookie(orderGoods))
			console.log(obj);
			$(".tell").html(getCookie(myUserName));
			$(".orderliebiao").append("<tr><td>"+
					getCookie(orderNumber)+"</td><td>"+
					obj.time+"</td><td>"+
					obj.prise+"</td><td>待付款</td><td><a href='javascript:void(0)' class='shanchu'>删除</a></td></tr>");
		}
		$(".shanchu").on("click",function(){
			$(this).parent().parent().parent().remove();
			deleteCookie(orderGoods);
		});
	};
	//我的订单的显示功能
	orderShow();
	function orderShow(){
		var obj = JSON.parse(getCookie(orderGoods))
		$(".tell").html(getCookie(myUserName));
		$(".detail_order").append("<tr><td>"+
				getCookie(orderNumber)+"</td><td><img class='og' src='"+
				obj.img+"'></td><td>"+
				obj.prise+"</td><td>"+
				obj.time+"</td><td>待付款</td><td><a href='javascript:void(0)' class='shanchu'>删除</a></td></tr>");
	};
	//密码的重置功能
	resetMiMa();
	function resetMiMa(){
		$("#oldPwd,#cNewPwd").on("focus",function(){
			$(".oldPwd_error").hide();
			$(".newPwd_error").hide();
		});
		$("#oldPwd").on("blur",function(){
			if(getCookie(myPwd) != $(this).val()){
				$(".oldPwd_error").show();
			}else{
				$("#cNewPwd").on("blur",function(){
					if($("#cNewPwd").val() != $("#newPwd").val()){
						$(".newPwd_error").show();
					}else{
						submitPwd();
					};
				});
			};
		});
	}
	function submitPwd(){
		$(".save").on("click",function(){
			updateCookie(myPwd,$("#newPwd").val(),5);
			alert("密码修改成功");
			window.location = "usercenter.html";
		});
	};
	//管理收货地址
	addressShow();
	function addressShow(){
		var obj = JSON.parse(getCookie(userAddress))
		console.log(obj)
		$(".showAddress").append("<tr><td>"+
				obj.name+"</td><td>"+
				obj.address1+"-"+obj.address2+"-"+obj.address1+"</td><td>"+
				obj.detailAddress+"</td><td></td><td>"+
				obj.tell+"<td><a href='javascript:void(0)' class='shanchu'>删除</a></td></tr>");
		$(".shanchu").on("click",function(){
			$(this).parent().parent().parent().remove();
			updateCookie(isHaveAddress,0,0);
			deleteCookie(userAddress);
		});
	};
}
$(function(){
	start();
});